Ext.util.Router = Ext.extend(Ext.util.Observable, {
    
    constructor: function(config) {
        config = config || {};

        Ext.apply(this, config, {
            defaults: {
                action: 'index'
            }
        });
        
        this.routes = []; // Ext.util.Route 对象数组

        Ext.util.Router.superclass.constructor.call(this, config);
    },
    
    
    connect: function(url, params) {
        params = Ext.apply({url: url}, params || {}, this.defaults);
        var route = new Ext.util.Route(params);
        
        this.routes.push(route);
        
        return route;
    },

    // 辨认满足条件的url，转换成对象
    recognize: function(url) {
        var routes = this.routes,
            length = routes.length,
            i, result;
        
        // 遍历已注册的Ext.util.Route 对象数组
        for (i = 0; i < length; i++) {
            result = routes[i].recognize(url); // 辨认满足条件的url，转换成对象
            
            if (result != undefined) {
                return result;
            }
        }
        return undefined;
    },
    
    
    draw: function(fn) {
        fn.call(this, this);
    }
});